home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / simula / books / books.lha / kirkerud / texttools.sim < prev    next >
Text File  |  1993-08-16  |  1KB  |  48 lines

  1. class texttools;
  2.   begin
  3.     
  4.     text procedure frontstrip(t); text t;
  5.       if t == notext or else t.strip == notext  
  6.         then frontstrip :- notext
  7.         else begin
  8.             t.setpos(1); 
  9.             while t.getchar = ' ' do;
  10.             frontstrip :- t.sub(t.pos-1, t.length-t.pos+2);
  11.           end;
  12.  
  13.     text procedure int_as_text(int); integer int;
  14.       begin text t;
  15.         t :- blanks(12);
  16.         t.putint(int);
  17.         int_as_text :- frontstrip(t);
  18.       end;
  19.  
  20.     text procedure char_as_text(char); character char;
  21.       begin text t;
  22.         t :- blanks(1);
  23.         t.putchar(char);
  24.         char_as_text :- t;
  25.       end;
  26.  
  27.     text procedure real_as_text(r, dig); real r; integer dig;
  28.       begin text t;
  29.         t :- blanks(12+dig);
  30.         t.putfix(r, dig);
  31.         real_as_text :- frontstrip(t);
  32.       end real_as_text;
  33.  
  34.     text procedure next_word_in(t); name t; text t;
  35.       if t == notext or else not t.more then next_word_in :- notext 
  36.       else begin character c; text word;
  37.           c := t.getchar; 
  38.           while c = ' ' and t.more do c := t.getchar;
  39.           while c ne ' ' do 
  40.             begin
  41.               word :- word & char_as_text(c);
  42.               c := if t.more then t.getchar else ' ';
  43.             end;
  44.           next_word_in :- word;
  45.         end;
  46.  
  47.  
  48.   end texttools;